package day06;
import java.util.Arrays;

            //************第二遍作业**************

    public class MaxOfArray2 {
        public static void main(String[] args) {
            int[]arr2 = new int[10];

            for (int i = 0; i < arr2.length; i++) {
                arr2[i] = (int) (Math.random()*1000);
                    System.out.println(arr2[i]);
        }
                int max2= arr2[0];
            for (int i = 1; i < arr2.length; i++) {
                if ( arr2[i]>max2) {
                    max2 =arr2[i] ;
              }
            }
                System.out.println("最大值是:"+max2);

            arr2 = Arrays.copyOf(arr2,arr2.length+1);//扩容
            arr2[arr2.length-1] = max2;//将最大值放在最后
            for (int i = 0; i < arr2.length; i++) {
                System.out.println(arr2[i]);
        }
    }
}

